package main

import "fmt"

type A interface {
}

func show(x interface{}) {
	fmt.Printf("type: %T \t val: %v\n", x, x)
}

func main() {
	//var y interface{}
	var x A = "hello golang"
	fmt.Printf("%T %v\n", x, x)
	fmt.Println("-----------------------------------------------")

	show(1)
	show(1.2)
	show('a')
	show("hello")
	show(false)
	slice := []interface{}{1, true, 1.2}
	show(slice)
	map1 := map[string]interface{}{
		"name": "chj",
		"age":  20,
	}
	show(map1)
	fmt.Println("-----------------------------------------------")
	s, ok := x.(string)
	fmt.Println(ok, s)
	fmt.Println("-----------------------------------------------")
	switch x.(type) {
	case string:
		fmt.Println("string")
	case int:
		fmt.Println("int")
	case bool:
		fmt.Println("bool")
	default:
		fmt.Println("unknown")
	}

}
